package com.huawei.gamebox;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse;
import com.huawei.appmarket.R;
import com.huawei.appmarket.framework.MainActivityBase;
import com.huawei.appmarket.framework.fragment.GameCenterStartUpLoadingFragment;
import com.huawei.appmarket.service.common.protocol.AppActivityProtocol;
import com.huawei.appmarket.service.plugin.receiver.CommonActivityReceiver;
import com.huawei.appmarket.support.widget.tabhost.FragmentTabHost;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant.KeyAndValue;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.huawei.secure.android.common.intent.SafeIntent;
import huawei.widget.HwBottomNavigationView;
import o.ccx;
import o.ceh;
import o.PermissionChecker;
import o.cfw;
import o.cjk;
import o.cjm;
import o.cvt;
import o.dgh;
import o.dgm;
import o.dgo;
import o.dgr;
import o.dgt;
import o.Logger;
import o.NetWorkUtls;
import o.ActivityUtil;

public class GameBoxMainActivity extends MainActivityBase<AppActivityProtocol> implements ceh {
    private CommonActivityReceiver ʾ;
    protected NetWorkUtls ˊॱ;

    public void onCreate(Bundle bundle) {
        dgm.ˋ(1, this);
        cvt o_dgt = new dgt("desktop|" + 1);
        o_dgt.setServiceType_(1);
        cfw.ˎ(o_dgt, new dgo("GameCenterActivity"));
        dgr.ˋ().ˊ();
        AppActivityProtocol appActivityProtocol = (AppActivityProtocol) ʾ();
        if (!(appActivityProtocol == null || appActivityProtocol.ˋ() == null)) {
            this.ᐝॱ = ((AppActivityProtocol) ʾ()).ˋ().ˊ();
            this.ʻॱ = ((AppActivityProtocol) ʾ()).ˋ().ˋ();
        }
        super.onCreate(bundle);
        if (ccx.ॱ()) {
            ˋ(this);
            if (new SafeIntent(getIntent()).getBooleanExtra("isFromShortCut", false)) {
                dgh.ॱ(getApplicationContext(), "01060410", KeyAndValue.NUMBER_01);
            }
            PermissionChecker.ˋ(this, 14);
            return;
        }
        Logger.ˎ("GameCenterActivity", "protocol not agree");
        cjm o_cjm = new cjm("main.activity", null);
        o_cjm.ॱ(this).addFlags(HwAccountConstants.FLAG_TRANSLUCENT_STATUS);
        o_cjm.ॱ(this).addFlags(268435456);
        cjk.ˎ().ˋ(this, o_cjm);
        finish();
    }

    public void doubleExist() {
    }

    public void ᐝ() {
        setContentView(R.layout.market_activity);
        this.tabHost = (FragmentTabHost) findViewById(16908306);
        ᐨ();
    }

    public int ͺ() {
        return R.id.main_view_layout;
    }

    private void ᐨ() {
        this.mBottomNavigationView = (HwBottomNavigationView) findViewById(R.id.hiapp_mainscreen_bottomtab);
        wrapperNavigator(this.mBottomNavigationView);
    }

    public void onDestroy() {
        dgm.setEnd(1);
        super.onDestroy();
        if (this.ˊॱ != null) {
            this.ˊॱ.dismiss();
        }
        ActivityUtil.unregisterReceiver(this, this.ʾ);
    }

    public void excuteStateOfLogin(StartupResponse startupResponse) {
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == R.id.action_settings) {
            return ˊˊ();
        }
        return super.onOptionsItemSelected(menuItem);
    }

    public boolean ˊˊ() {
        if (getActionBar() != null) {
            getActionBar().hide();
        }
        return true;
    }

    public TaskFragment ॱˊ() {
        return new GameCenterStartUpLoadingFragment();
    }

    public boolean ˋ(TaskFragment taskFragment, StartupResponse startupResponse) {
        if (!(taskFragment instanceof GameCenterStartUpLoadingFragment)) {
            return false;
        }
        ((GameCenterStartUpLoadingFragment) taskFragment).ˏ(startupResponse.getResponseCode(), true);
        return true;
    }

    public void ॱ(TaskFragment taskFragment) {
        if (taskFragment instanceof GameCenterStartUpLoadingFragment) {
            ((GameCenterStartUpLoadingFragment) taskFragment).ˏ(0, false);
        }
    }

    public int ᐝॱ() {
        return R.id.mainwindows_layout;
    }

    private void ˋ(Activity activity) {
        this.ʾ = new CommonActivityReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.huawei.hwid.ACTION_REMOVE_ACCOUNT");
        ActivityUtil.registerReceiver(activity, intentFilter, this.ʾ);
    }

    @TargetApi(23)
    public void onRequestPermissionsResult(int i, @NonNull String[] strArr, @NonNull int[] iArr) {
        if (14 == i && iArr.length != 0) {
            PermissionChecker.ˎ(this, i, strArr, iArr);
        }
    }

    public void ˏ(int i, int i2) {
        if (i2 == -1) {
            ᐝˋ();
        }
    }

    @TargetApi(24)
    private void ᐝˋ() {
        boolean shouldShowRequestPermissionRationale = shouldShowRequestPermissionRationale("android.permission.READ_PHONE_STATE");
        if (this.ˊॱ == null) {
            this.ˊॱ = new NetWorkUtls();
        }
        this.ˊॱ.showDial(this, shouldShowRequestPermissionRationale, R.string.permission_deviceid_content, 14);
    }
}
